package gold.digger;

import java.util.*;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC633 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        Map<Integer, Integer> squareMap = new HashMap<>();

        public boolean judgeSquareSum(int c) {
            for (int i = 0; i <= (int) Math.sqrt(c); i++) {
                int remain = c - i * i;
                if (isSquare(remain)) return true;
            }

            return false;
        }

        public boolean isSquare(int c) {
            int sub = (int) Math.sqrt(c);
            return sub * sub == c;
        }

    }

    public void run() {
        Solution solution = new Solution();
        for (int i = 1; i <= 10; i++) {
            System.out.println(i + " : " + solution.judgeSquareSum(i));
        }
    }

    public static void main(String[] args) throws Exception {
        LC633 an = new LC633();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
